1. Field of the Invention
The present invention relates to the field of computer graphics and, in particular, to a system and method for calculating volumetric obscurance.
2. Description of the Related Art
Obscurance and ambient occlusion (AO) are popular techniques in both film and games that model how ambient light is shadowed. These techniques provide a way to approximate the lighting on a surface without performing computationally expensive operations such as radiosity, global illumination, or full ray tracing.
One prior art technique for calculating ambient occlusion involves projecting rays from a point on a surface. FIG. 1A is a conceptual diagram illustrating a technique for calculating ambient occlusion based on projecting rays, according to the prior art. In various implementations, the rays can extend from a point 102 on surface for a finite length or to infinity. The technique involves determining a ratio of the number of rays that hit another object 104 to the number of rays that do not hit any objects. The greater the ratio, the greater the occlusion of the point 102. For example, if 75% of the rays do not intersect any objects and 25% of the rays do interest an object, then the lighting value for the point 102 may be scaled down by 75% or by some other factor. Additionally, weight values may be applied to the ratio calculation so that rays that intersect objects at a greater distance from point 102 have less impact on the ambient occlusion value. Although this technique provides adequate results, projecting rays is very computationally expensive and is not readily adaptable to real-time applications, such as video and games.
Other prior art techniques involve point sampling-based screen space ambient occlusion. FIG. 1B is a conceptual diagram illustrating a technique for calculating point sampling-based screen space ambient occlusion, according to the prior art. A screen space depth buffer (i.e., a “z buffer”) 202 is provided for each pixel location in the image relative to an observer 212. For a given pixel location 204, a sphere 206 having a radius R is drawn around the pixel location 204. Then, the sphere 206 is sampled at various points. FIG. 1B shown only a two-dimensional (2D) cross-section of the sphere 206. The depth value of each sample point is compared to the depth value at that particular pixel location in the depth buffer 202. A ratio is then calculated based on the number of samples within the sphere 206 that are “in front” of the corresponding depth buffer value and the number of samples within the sphere 206 that are “behind” the corresponding depth buffer value. As shown in FIG. 1B, the samples 208 (illustrated as empty circles) are in front of the depth buffer 202 at the corresponding pixel locations; whereas, the samples 210 (illustrated as filled circles) are behind the depth buffer 202 at the corresponding pixel locations. A ratio of these points is then used to scale the lighting value at the pixel location 204. Weighting of point samples may also be used so that points closer to the pixel location 204 affect the result more than point samples further away from the pixel location 204. However, the screen space ambient occlusion technique suffers from several drawbacks. First, under-sampling can result in a coarse or noisy image. A blurring operation is typically performed to smooth out the results of the point sampling-based screen space ambient occlusion technique. The blurring operation typically must respect edges so that only those neighboring pixels that have a similar depth/normal are blurred. Performing the blurring operation adds additional computational complexity to this technique. Second, artifacts can result since the depth buffer 202 is typically a single-layer depth buffer that does not take into account multiple depth layers.
As the foregoing illustrates, there is a need in the art for an improved technique for calculating ambient occlusion that overcomes the limitations of conventional approaches.